package com.cf.utils;

import java.io.File;

import org.springframework.web.multipart.MultipartFile;

public class UploadFile {
	public static Boolean saveUpload(MultipartFile file, String url) {
		if (file.isEmpty()) {
			return false;// R.error().put("retMsg", "上传文件为空！");
		}
		String fileName = file.getOriginalFilename();
		// File dest = new File("e:\\upload\\", fileName);
		File dest = new File(url, fileName);
		if (!dest.getParentFile().exists()) {
			dest.getParentFile().mkdirs();
		}
		try {
			file.transferTo(dest); // 保存文件
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

}
